package BaseObject.ploy;

/**
 * ClassName: PloyParmeter
 * Package: BaseObject.ploy
 * Description: 多态的运用
 *
 * @Author Linshio
 * @Create 2025/3/16 15:01
 */
public class PloyParameter {
    public static void main(String[] args) {
        People people = new People();
        Manager manager = new Manager();
        people.setSalary(2000);
        showEmpAnnal(people);
        manager.setSalary(4000);
        manager.setBonus(666);
        showEmpAnnal(manager);
        testWork(people);
        testWork(manager);
    }
    public static void showEmpAnnal(Employee employee){
        System.out.println("employee.getAnnual() = " + employee.getAnnual());
    }

    public static void testWork(Employee employee){
        if (employee instanceof People){
            People people = (People) employee;
            people.work();
        }else if(employee instanceof Manager){
            Manager manager = (Manager)employee;
            manager.mananger();
        }
    }
}
